﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data;
using KPIS.GERP.GHRMS.DAL;
using KPIS.GERP.GHRMS.MODEL;
using KPIS.GERP.GHRMS.IBLL;
using KPIS.GERP.GHRMS.IDAL;
using KPIS.GERP.GHRMS.DALFactory;

namespace KPIS.GERP.GHRMS.BLL
{
    public class MasProvinceBLL : IMasProvinceBLL
    {
        private static readonly IMasProvinceDAL dal = DataAccess.CreateMasterProvinces();

        private MasRegionInfo regInfo = new MasRegionInfo();
        public IList<MasProvinceInfo> ListMasProvinces()
        {
            return dal.ListMasProvinces(new MasProvinceInfo(0));
        }
        public IList<MasProvinceInfo> ListMasProvinces(string Sequence, string Regions)
        {
            int Seq = Sequence.Length > 0 ? Int32.Parse(Sequence) : 0;
            int regSeq = Regions.Length > 0 ? Int32.Parse(Regions) : 0;

            return dal.ListMasProvinces(new MasProvinceInfo(Seq, "", "", new MasRegionInfo(regSeq), null, null));
        }
        public DataSet LoadMasProvinces(Nullable<int> Sequence, Nullable<int> Region)
        {
            return dal.LoadMasProvinces(Sequence, Region);
        }
        public void Insert(string Name, string NameEng, int Region, int CreatedBy)
        {
            try
            {
                regInfo.Sequence = Region;
                dal.Insert(new MasProvinceInfo(0, Name, NameEng, regInfo, CreatedBy, 0));
            }
            catch
            {
                throw new Exception("");
            }
        }
        public void Update(int Sequence, string Name, string NameEng, int Region, int UpdatedBy)
        {
            try
            {
                regInfo.Sequence = Region;
                dal.Update(new MasProvinceInfo(Sequence, Name, NameEng, regInfo, 0, UpdatedBy));
            }
            catch
            {
                throw new Exception("");
            }
        }
        public void Delete(int Sequence, int UpdatedBy)
        {
            try
            {
                dal.Delete(Sequence, UpdatedBy);
            }
            catch
            {
                throw new Exception("");
            }
        }
    }
}
